package lesbonsamis

class Projet {
	
	String				cle
	String				nom
	Participant			responsable
	Integer				totalDepense = 0
	
	List<Depense> 		depenses = new ArrayList()
	List<Participant>	participants = new ArrayList()
	
	List<TransactionCommand> transactions = new ArrayList()
	
	static hasMany = [	depenses : Depense,
						participants : Participant,
						transactions : TransactionCommand	]
	
	static transients = ['transactions']
	
    static constraints = {
		cle nullable: true, unique: true
    }

	def beforeInsert() {
		cle = UUID.randomUUID().toString()
	}
	
	static mapping = {
		cle generator:'guid'
		sort transactions:"donneur"
	}
	
	/* GET SET OVERRIDE */
	
	void setTotalDepense(String s) {
		totalDepense = Utils.depuisDevise(s);
	}
	String getTotalDepense() {
		return Utils.versDevise(totalDepense);
	}
	void setTotalDepenseVal(Integer i) {
		totalDepense = i
	}
	Integer getTotalDepenseVal() {
		return totalDepense
	}
}
